package com.wmx.blockingQueue;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

public class MyTaskTest {
    public static void main(String[] args) throws InterruptedException {
        MyTask myTask = new MyTask(new ArrayBlockingQueue(10));
        new Thread(() -> {
            try {
                myTask.myProd();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "prod").start();

        new Thread(() -> {
            try {
                myTask.myConsumer();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "consumer").start();

        TimeUnit.SECONDS.sleep(50);
        myTask.stop();
    }
}
